/*********************************************************************************
 *      Copyright:  (C) 2022 Li Yanting<liyanting2@163.com>
 *                  All rights reserved.
 *
 *       Filename:  get_time.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(07/2/2022)
 *         Author:  Li Yanting <liyanting2@163.com>
 *      ChangeLog:  1, Release initial version on "07/02/2022 17:18:08"
 *                 
 ********************************************************************************/
#include "get_time.h"

void gtime(long *t)
{
   *t = (long)time(NULL);
}


char * get_format_time(long t)
{
    static char           buf[128];
    struct tm            *p;
	time_t                timep;
    int                   hour;

	timep = (time_t)t;
    p = gmtime(&timep);
	
    if( (8 + p->tm_hour) >= 24 )
    {
        hour = 8 + p->tm_hour - 24;
    }
    else
    {
        hour = 8 + p->tm_hour;
    }

	sprintf(buf, "%02d-%02d-%02d %02d:%02d:%02d", 1900+p->tm_year, 1+p->tm_mon, p->tm_mday, hour, p->tm_min, p->tm_sec);

	return buf;
}

// int get_time(char *current_time)
// {
//     time_t             time_val;
//     struct tm         *p;

//     time(&time_val);
//     p=gmtime(&time_val);

// 	sprintf(current_time, "%d-%d-%d %d:%d:%d", 1900+p->tm_year, 1+p->tm_mon, p->tm_mday, 8+p->tm_hour, p->tm_min, p->tm_sec);
    
//     return 0;
// }



